<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>

<script src="${ctx}/includes/jquery.js" type="text/javascript"></script>
<script src="${ctx}/includes/jquery.validate.js" type="text/javascript"></script>
<script src="${ctx}/includes/jquery.form.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="${ctx}/style/form_table.css">
<script>
$(function(){
	$("#edit_taskSs_form").validate({
		errorPlacement: function(error, element){
            $(element).next('.field_notice').hide();
            $(element).after(error);
       },
	   success: function(label){   
	       label.addClass('right').text('OK!');
	   },
	   rules:   
	   {
	    	ssly : {required : true},
	    	zt : {required : true},
	    	bzxm : {required : true}
	   },   
	   message:{
	    	ssly : {required : '请输入申诉理由'},
	    	zt : {required : '请选择处理状态'},
	    	bzxm : {required : '请选择部门领导'}
	   }
	});  
});
</script>
<s:form id="edit_taskSs_form" name="edit_taskSs_form" method="post" action="taskReturn/ss.do" onsubmit="return false;">
	<s:token/>
	<s:hidden name="trid" />
	<c:if test="${zt == -1}">
		<table class="form-table">
			<tr>
				<th width="150">申诉理由：</th>
				<td>
					<s:textarea rows="4" name="ssly" id="ssly" style="width: 500px;"></s:textarea>
				</td>
			</tr>
			<tr>
				<th width="150"><span class="note_red">*</span>部门领导：</th>
				<td>
				<s:hidden name="bz" id="zrrbh"/>
				<s:textfield name="bzxm" title="请输入部门领导" cssClass="form-txtinput" id="zrr" maxlength="20" value="%{model.hander}" readonly="true"/>
				</td>
			</tr>
		</table>
		<div class="win-btn-panel" style="text-align: center;margin-top: 5px;">
			<input class="btn-short" type="button" name="subbtn" id="ss" value=" 申 诉 " title="点击提交" onClick="ssTask();"/>
		</div>
	</c:if>
	<c:if test="${zt == -2 or zt == 0 or zt == 3}">
		<table class="form-table">
			<tr>
				<th width="150">退回人：</th>
				<td>
				${realname }
				</td>
			</tr>
			<tr>
				<th width="150">退回时间：</th>
				<td>
				${thsjString }
				</td>
			</tr>
			<tr>
				<th width="150">申诉人：</th>
				<td>
				${ssrxm }
				</td>
			</tr>
			<tr>
				<th width="150">申诉时间：</th>
				<td>
				${sssjString }
				</td>
			</tr>
			<tr>
				<th width="150">申诉理由：</th>
				<td>
				${ssly }
				</td>
			</tr>
			<tr>
				<th width="150">申诉结果：</th>
				<td>
				${ssjg }
				</td>
			</tr>
			<tr>
				<th width="150">部门领导：</th>
				<td>${bzxm}</td>
			</tr>
			<c:if test="${ggxm != null}">
			<tr>
				<th width="150">高层管理：</th>
				<td>${ggxm}</td>
			</tr>
			</c:if>
			<tr>
				<th width="150">状态：</th>
				<td>
					<c:if test="${zt == 3}">高层处理</c:if>
					<c:if test="${zt == -2}">待处理</c:if>
					<c:if test="${zt == -1}">未处理</c:if>
					<c:if test="${zt == 0}">处理中</c:if>
					<c:if test="${zt == 1}">申诉成功</c:if>
					<c:if test="${zt == 2}">申诉失败</c:if>
				</td>
			</tr>
			<tr>
				<th width="150">申诉结果：</th>
				<td>
					<s:textarea rows="4" name="ssjg" title="请输入申诉结果" id="ssjg" style="width: 500px;"></s:textarea>
				</td>
			</tr>
			<tr>
				<th width="150">状态：</th>
				<td>
				<s:select name="zt" list="#{'':'--请选择--','1':'申诉成功','2':'申诉失败'}"></s:select>
				</td>
			</tr>
			<c:if test="${gg == null and zt != 3}">
			<tr>
				<th width="150">是否向上申诉：</th>
				<td>
					<input type="radio" name="optAction" value="0" checked="checked" onclick="sfssgg(0)" id="noxzss"/>否
					<input type="radio" name="optAction" value="1" onClick="sfssgg(1)" id="xzss"/>是
				</td>
			</tr>
			<tr id="ggxz" style="display: none;">
				<th width="150"><span class="note_red">*</span>高层管理：</th>
				<td>
				<%-- 
				<s:hidden name="gg" id="zrrbh"/>
				<s:textfield name="ggxm" title="请输入高层管理" cssClass="form-txtinput" id="zrr" maxlength="20" value="%{model.hander}" readonly="true"/>
				--%>
				<mytag:select id="gg" title="请选择审核人" name="gg" sql="leader" isSql="false" listKey="userid" listValue="realname" headerKey="" headerValue="请选择"/>
				</td>
			</tr>
			</c:if>
		</table>
		<div class="win-btn-panel" style="text-align: center;margin-top: 5px;">
			<input class="btn-short" type="button" name="subbtn" id="cl" value=" 处理完成 " title="点击提交" onClick="clTask();"/>
			<c:if test="${gg == null and zt !=3}">
			<input class="btn-short" type="button" name="subbtn" id="ggss" value=" 申 诉 " title="点击提交" onClick="ss2Task();"/>
			</c:if>
		</div>
	</c:if>
	<c:if test="${zt == 1 or zt == 2}">
		<table class="form-table">
			<tr>
				<th width="150">退回人：</th>
				<td>
				${realname }
				</td>
			</tr>
			<tr>
				<th width="150">退回时间：</th>
				<td>
				${thsjString }
				</td>
			</tr>
			<tr>
				<th width="150">申诉人：</th>
				<td>
				${ssrxm }
				</td>
			</tr>
			<tr>
				<th width="150">申诉时间：</th>
				<td>
				${sssjString }
				</td>
			</tr>
			<tr>
				<th width="150">申诉理由：</th>
				<td>
				${ssly }
				</td>
			</tr>
			<tr>
				<th width="150">申诉结果：</th>
				<td>
				${ssjg }
				</td>
			</tr>
			<tr>
				<th width="150">状态：</th>
				<td>
					<c:if test="${zt == 3}">高层处理</c:if>
					<c:if test="${zt == -2}">待处理</c:if>
					<c:if test="${zt == -1}">未处理</c:if>
					<c:if test="${zt == 0}">处理中</c:if>
					<c:if test="${zt == 1}">申诉成功</c:if>
					<c:if test="${zt == 2}">申诉失败</c:if>
				</td>
			</tr>
		</table>
	</c:if>
</s:form>

<table class="form-table">
	<caption>任务信息</caption>
	<tr>
		<td>
			<iframe src="${ctx}/task_show.do?taskid=${taskid}" frameborder="0" width="100%" height="400"></iframe>
		</td>
	</tr>
</table>
<script type="text/javascript">
$('#zrr').click(function(){
	parent.$.dialog({
	  	id:'abc', 
	  	title:'选择人员', 
	  	content: 'url:${ctx}/pub/userByDeptSelect.jsp?timestamp='+new Date().getTime(), 
	  	max:false,
	  	min:false,
	  	width:600, 
	  	height:450,
	  	ok: function(){ 
	       	var m = parent.abc.selectOnlyUserByTask();
	        return m; 
	    }, 
	    cancelVal: '关闭', 
	    cancel: true
  	});
});

/*申诉*/
function ssTask(){
	var v = $("#edit_taskSs_form").valid();
	if(!v)return false;
	
	$('#edit_taskSs_form').attr("action","${ctx}/taskReturn/ss.do");
	$('#edit_taskSs_form').ajaxSubmit(resultHandler);
    return false;
    
}

/*申诉2*/
function ss2Task(){
	var v = $("#edit_taskSs_form").valid();
	if(!v)return false;
	
	var sfggss = document.getElementById('xzss');
	if(sfggss.checked){
		var gg = $('#gg').val();
		if(gg == ''){alert('请选择高管');}
	}else{
		alert('请选择上诉申请');
		return false;
	}
	$('#edit_taskSs_form').attr("action","${ctx}/taskReturn/ss2.do");
	$('#edit_taskSs_form').ajaxSubmit(resultHandler);
    return false;
}

/*处理*/
function clTask(){
	var v = $("#edit_taskSs_form").valid();
	if(!v)return false;
	
	$('#edit_taskSs_form').attr("action","${ctx}/taskReturn/update.do");
	$('#edit_taskSs_form').ajaxSubmit(resultHandler);
    return false;
    
}

function resultHandler(responseXML){
	var result = responseXML.getElementsByTagName("result")[0].firstChild.nodeValue;
	var message = responseXML.getElementsByTagName("error-message")[0].firstChild.nodeValue;
	var errorType = responseXML.getElementsByTagName("error-type")[0].firstChild.nodeValue;
	if(!eval(result)&&(errorType!=2)){
		alert(message);
	}
	else{
		var curDate = new Date(); 
		alert(message);
		parent.location.replace("${ctx}/taskReturn/my.do?opt=return&timsStamp=" + curDate.getTime());
	}
}
function sfssgg(A){
	if(A == 0){
		$('#ggxz').attr('style','display:none');
	}else{
		$('#ggxz').removeAttr('style');
	}
}
</script>
